home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / fractals / mandelsquare / mandelsquare-1.06.lha / Plot.asm < prev    next >
Assembly Source File  |  1992-09-01  |  3KB  |  105 lines

  1. **
  2. **    MandelSquare - AmigaDOS 2.0/3.0 Mandelbrot set explorer
  3. **
  4. **    Plot.asm, Assembly-language routines to write/read pixels
  5. **
  6. **    Copyright © 1991-1992 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9.  
  10.     include    "graphics/gfx.i"
  11.  
  12.     csect    text,0,0,1,2
  13.  
  14.     xdef    _Plot
  15.     xdef    _Test
  16.  
  17. ;    VOID __asm Plot(register __a0 struct BitMap *,register __d0 WORD X,register __d1 WORD Y,register __d2 WORD Colour);
  18. ;
  19. ;        Fast pixel drawing routine, somewhat equivalent to
  20. ;    graphics.library/WritePixel.
  21. ;
  22. ;    Register usage is as follows:
  23. ;
  24. ;        d1    = Byte offset into bitplane
  25. ;        d2    = Pixel colour
  26. ;        d3    = Number of bitplanes
  27. ;        d4    = Line modulo/pixel number
  28. ;        a0    = Pointer to array of bitplanes
  29. ;        a1    = Pointer to bitplane
  30.  
  31. _Plot:    movem.l    d3/d4,-(sp)        ; Save registerrs
  32.  
  33.     moveq    #0,d4            ; Clear d3 & d4
  34.     move.l    d4,d3
  35.  
  36.     move.w    bm_BytesPerRow(a0),d4    ; Get line modulo
  37.     move.b    bm_Depth(a0),d3        ; Get bitmap depth
  38.     lea.l    bm_Planes(a0),a0    ; Get array of planes
  39.  
  40.     mulu.l    d4,d1            ; Multiply Y-position by modulo
  41.     move.l    d0,d4            ; Save X-position
  42.     lsr    #3,d0            ; Get byte offset of X-position 
  43.     add    d0,d1            ; Add byte offsets
  44.     not    d4            ; Get bit number
  45.     subq    #1,d3            ; One plane less (for dbra)
  46.  
  47. loop    move.l    (a0)+,a1        ; Get next plane
  48.     lsr.b    #1,d2            ; Clear or set the pixel?
  49.     bcc    clear
  50.     bset    d4,0(a1,d1)        ; Set pixel
  51.     dbra    d3,loop            ; Loop until all planes are done
  52.  
  53. exit    movem.l    (sp)+,d3/d4        ; Restore registers
  54.     rts
  55.  
  56. clear    bclr    d4,0(a1,d1)        ; Clear pixel
  57.     dbra    d3,loop            ; Loop until all planes are done
  58.     bra    exit
  59.  
  60. ;    BYTE __asm Test(register __a0 struct BitMap *,register __d0 WORD X,register __d1 WORD Y);
  61. ;
  62. ;        Fast pixel reading routine, somewhat equivalent to
  63. ;    graphics.library/ReadPixel, returns 1 if there is a pixel in
  64. ;    the given position in bitmap, else 0.
  65. ;
  66. ;    Register usage is as follows:
  67. ;
  68. ;        d1    = Byte offset into bitplane
  69. ;        d3    = Number of bitplanes
  70. ;        d4    = Line modulo/pixel number
  71. ;        a0    = Pointer to array of bitplanes
  72. ;        a1    = Pointer to bitplane
  73.  
  74. _Test:    movem.l    d3/d4,-(sp)        ; Save registerrs
  75.  
  76.     moveq    #0,d4            ; Clear d3 & d4
  77.     move.l    d4,d3
  78.  
  79.     move.w    bm_BytesPerRow(a0),d4    ; Get line modulo
  80.     move.b    bm_Depth(a0),d3        ; Get bitmap depth
  81.     lea.l    bm_Planes(a0),a0    ; Get array of planes
  82.  
  83.     mulu.l    d4,d1            ; Multiply Y-position by modulo
  84.     move.l    d0,d4            ; Save X-position
  85.     lsr    #3,d0            ; Get byte offset of X-position
  86.     add    d0,d1            ; Add byte offsets
  87.     not    d4            ; Get bit number
  88.     sub.w    #1,d3            ; One plane less (for dbra)
  89.     moveq    #0,d0            ; So we have valid return code
  90.  
  91. tloop    move.l    (a0)+,a1        ; Get next plane
  92.     btst    d4,0(a1,d1)        ; Is a pixel in this position?
  93.     bne.s    go            ; Yes, there is
  94.     dbra    d3,tloop        ; Test next plane
  95.  
  96.     movem.l    (sp)+,d3/d4        ; Restore registers
  97.     rts
  98.  
  99. go    moveq    #1,d0            ; Got a pixel
  100.  
  101.     movem.l    (sp)+,d3/d4        ; Restore registers
  102.     rts
  103.  
  104.     end
  105.